<template>
  <div style="boxs">
    <!-- <Header :params="params" /> -->
    <div class="content">
      <van-cell-group>
        <van-field v-model="userGexing" @input="valInput" placeholder="请输入少于25个字符" maxlength="25" />
      </van-cell-group>
      <div class="btn">
        <van-button type="info" size="mini" :disabled="flag" @click="save">保 存</van-button>
      </div>
    </div>
  </div>
</template>
<script>
import Header from "@/components/Header.vue";
export default {
  components: {
    Header,
  },
  data() {
    return {
      params: {
        left: true,
        title: "个性签名",
      },
      flag: true,
      userGexing: "",
    };
  },
  mounted() {
    this.userGexing = this.$route.query.userGexing;
    if (this.userGexing.length > 0) {
      this.flag = false;
    } else {
      this.flag = true;
    }
  },
  methods: {
    valInput(val) {
      if (val.length > 0) {
        this.flag = false;
      } else {
        this.flag = true;
      }
    },
    // 保存
    save() {
      (async () => {
        const data = await this.get("/user/addUserGexingQianming", {
          geXingQianMing: this.userGexing,
          userId: localStorage.getItem("id"),
        });
        if (data.code == 200) {
          this.$toast.success(data.msg);
          this.$router.back();
        } else {
          this.$toast.fail(data.msg);
        }
      })();
    },
  },
};
</script>
<style lang="scss" scoped>
.boxs {
  width: 100%;
}
.content {
  padding: 0 0.24rem;
  .van-cell-group {
    .van-cell {
      padding-left: 0;
      padding-right: 0;
      font-size: 0.28rem;
      font-family: PingFang SC;
      font-weight: 500;
      color: #5f5f5f;
    }
    border-bottom: 0.01rem #2d9dff solid;
  }
  .btn {
    font-size: 0.1rem;
    text-align: right;
    margin-top: 0.2rem;
  }
}
</style>